/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FormAberturaChamados.java
 *
 * Created on 06/12/2011, 01:13:30
 */

package sistemachamados.view;

import classes.Usuario;
import javax.swing.JDialog;
import javax.swing.JOptionPane;

/**
 *
 * @author Cleber Lopes
 */
public class FormAlterarSenha extends javax.swing.JInternalFrame {
//public class FormAberturaChamados extends JDialog {

    private Usuario usuarioLogado;
    /** Creates new form FormAberturaChamados */
    public FormAlterarSenha(Usuario usuarioLogado) {
        initComponents();
        this.usuarioLogado = usuarioLogado;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
        jButton2 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jLabel8 = new javax.swing.JLabel();
        txtSenhaAtual = new javax.swing.JTextField();
        txtNovaSenha = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        txtrepeticaoNovasenha = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();

        setBorder(null);
        setClosable(true);
        setFrameIcon(null);
        setInheritsPopupMenu(true);
        setMinimumSize(new java.awt.Dimension(990, 470));
        setPreferredSize(new java.awt.Dimension(990, 470));
        getContentPane().setLayout(null);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "ALTERAR SENHA", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Showcard Gothic", 0, 16))); // NOI18N
        jPanel2.setFont(new java.awt.Font("Showcard Gothic", 0, 16));
        jPanel2.setName("jPanel2"); // NOI18N
        jPanel2.setOpaque(false);
        jPanel2.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jButton2.setFont(new java.awt.Font("Berlin Sans FB Demi", 0, 16));
        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sistemachamados/view/resources/Xicon.png"))); // NOI18N
        jButton2.setText("Cancelar");
        jButton2.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jButton2.setName("jButton2"); // NOI18N
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        jPanel2.add(jButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(290, 150, 130, -1));

        jButton4.setFont(new java.awt.Font("Berlin Sans FB Demi", 0, 16));
        jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sistemachamados/view/resources/ViconUsado.png"))); // NOI18N
        jButton4.setText("Salvar");
        jButton4.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jButton4.setName("jButton4"); // NOI18N
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });
        jPanel2.add(jButton4, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 150, 120, -1));

        jLabel8.setFont(new java.awt.Font("Gautami", 3, 16));
        jLabel8.setText("Senha Atual");
        jLabel8.setName("jLabel8"); // NOI18N
        jPanel2.add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 40, -1, -1));

        txtSenhaAtual.setFont(new java.awt.Font("Tahoma", 0, 12));
        txtSenhaAtual.setName("txtSenhaAtual"); // NOI18N
        jPanel2.add(txtSenhaAtual, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 40, 212, -1));

        txtNovaSenha.setFont(new java.awt.Font("Tahoma", 0, 12));
        txtNovaSenha.setName("txtNovaSenha"); // NOI18N
        jPanel2.add(txtNovaSenha, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 70, 212, -1));

        jLabel9.setFont(new java.awt.Font("Gautami", 3, 16));
        jLabel9.setText("Nova Senha");
        jLabel9.setName("jLabel9"); // NOI18N
        jPanel2.add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 70, -1, -1));

        txtrepeticaoNovasenha.setFont(new java.awt.Font("Tahoma", 0, 12));
        txtrepeticaoNovasenha.setName("txtrepeticaoNovasenha"); // NOI18N
        jPanel2.add(txtrepeticaoNovasenha, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 100, 212, -1));

        jLabel10.setFont(new java.awt.Font("Gautami", 3, 16));
        jLabel10.setText("Repetição");
        jLabel10.setName("jLabel10"); // NOI18N
        jPanel2.add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 100, 100, 30));

        getContentPane().add(jPanel2);
        jPanel2.setBounds(250, 120, 500, 210);

        jLabel5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sistemachamados/view/resources/FORM PRINCIPAL (FUNDOPANEL).png"))); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N
        getContentPane().add(jLabel5);
        jLabel5.setBounds(0, 0, 980, 460);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        this.dispose();
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // TODO add your handling code here:
        if(txtNovaSenha.getText().equals(txtrepeticaoNovasenha.getText()))
        {
            usuarioLogado.setSenha(txtNovaSenha.getText());
            if(usuarioLogado.alterar(usuarioLogado))
            {
                JOptionPane.showMessageDialog(this, "Senha alterada.",
                                                    "Sucesso",
                                                     JOptionPane.INFORMATION_MESSAGE);
            }
        }
    }//GEN-LAST:event_jButton4ActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton4;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JTextField txtNovaSenha;
    private javax.swing.JTextField txtSenhaAtual;
    private javax.swing.JTextField txtrepeticaoNovasenha;
    // End of variables declaration//GEN-END:variables

}
